home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
tn3270
/
dialogs.c
< prev
next >
Wrap
Text File
|
1991-05-23
|
55KB
|
2,421 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.3d21, January 17, 1991
* Copyright (c) 1988, 1989, 1990, 1991 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistants Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#define __SEG__ 3270seg3
#include "maclib.h"
#include <Lists.h>
#include <CType.h>
#include "termdef.h"
#include "globals.h"
OSErr getapcr();
#define kButtonFrameSize 3 /* button frame's pen size */
#define kButtonFrameInset -4 /* inset rectangle adjustment around button */
extern char macFName[];
extern char macVName[];
extern char showstg;
char xdlg;
DialogPtr xdlgptr;
extern long textsize, pictsize;
extern char tcpinitok;
extern GDHandle bitmap_gdev;
extern char notifyavail;
extern nmrmessage *myNMR[NMRNUM];
extern struct Point sfgpoint;
OSErr notifymsg(unsigned char *);
char sessionhost[256];
char * dlgmapptr;
static short fmtmaxrows, fmtmaxcols;
aboutdlg()
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short * itemHitPtr;
short itemHit;
Handle version;
short gtype;
Handle gitem;
Rect gbox;
pascal unsigned short DlgFilter();
static unsigned short * DlgFont = (unsigned short *)0xAFA;
version = GetResource('GFTM', 0);
dStorage = 0;
behind = (WindowPtr)-1;
*DlgFont = 1;
dlgptr = GetNewDialog(256, dStorage, behind);
ctrwindow(dlgptr);
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
ptoc(*version);
SetIText(gitem, *version);
ctop(*version);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ModalDialog(filterProc, itemHitPtr);
if (itemHit == 2) showstg = 1;
DisposDialog(dlgptr);
*DlgFont = 0;
}
stginfo() /* display storage info. */
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short * itemHitPtr;
short itemHit;
short gtype;
Handle gitem;
Rect gbox;
pascal unsigned short DlgFilter();
char msg[120];
GDHandle currGD;
PixMapHandle currPM;
short i, j;
long l;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(270, dStorage, behind);
ctrwindow(dlgptr);
/* define info. text */
if (myWindow != 0) {
if (colormac) {
currPM = (*bitmap_gdev)->gdPMap;
i = (*currPM)->pixelSize;
j = 2 << (i-1);
sprintf(msg, "pixel depth = %d (%d colors)", i, j);
}
else {
sprintf(msg, "pixel depth = 1 (black & white)");
}
}
else {
if (colormac) {
currGD = GetMainDevice();
currPM = (*currGD)->gdPMap;
i = (*currPM)->pixelSize;
j = 2 << (i-1);
sprintf(msg, "pixel depth = %d (%d colors)", i, j);
}
else {
sprintf(msg, "pixel depth = 1 (black & white)");
}
}
GetDItem(dlgptr, 2, >ype, &gitem, &gbox);
SetIText(gitem, msg);
if (myWindow != 0) {
i = (textsize+1023) >> 10;
if (mapptr == 0) {
sprintf(msg, "no text bitmap (needs %dK)", i);
i = 0;
}
else sprintf(msg, "text bitmap = %dK", i);
}
else {
i = 0;
sprintf(msg, "no text bitmap (no session)");
}
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
SetIText(gitem, msg);
if (myWindow != 0) {
j = (pictsize+1023) >> 10;
if (pmapptr == 0) {
sprintf(msg, "no graphics bitmap (needs %dK)", j);
j = 0;
}
else sprintf(msg, "graphics bitmap = %dK", j);
}
else {
j = 0;
sprintf(msg, "no graphics bitmap (no session)");
}
GetDItem(dlgptr, 4, >ype, &gitem, &gbox);
SetIText(gitem, msg);
sprintf(msg, "bitmap total = %dK", i+j);
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
SetIText(gitem, msg);
MaxApplZone();
l = FreeMem() >> 10;
sprintf(msg, "available storage = %ldK", l);
GetDItem(dlgptr, 6, >ype, &gitem, &gbox);
SetIText(gitem, msg);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* show the text */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ModalDialog(filterProc, itemHitPtr);
DisposDialog(dlgptr);
}
attrdlg()
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short * itemHitPtr;
short itemHit;
short gtype;
Handle gitem;
Rect gbox;
unsigned char tempmap[35];
register short i, j;
register unsigned char c;
pascal unsigned short DlgFilter();
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(257, dStorage, behind);
ctrwindow(dlgptr);
/* handle attribute selection dialog */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
itemHit = 99;
j = 0;
for (i=0; i<7; i++) {
c = cs.attrmap[i] >> 3;
tempmap[j++] = (c & 0x10) >> 4;
tempmap[j++] = (c & 0x08) >> 3;
tempmap[j++] = (c & 0x04) >> 2;
tempmap[j++] = (c & 0x02) >> 1;
tempmap[j++] = c & 0x01;
}
for (i=0; i < 35; i++) {
GetDItem(dlgptr, i+18, >ype, &gitem, &gbox);
SetCtlValue(gitem, tempmap[i]);
}
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
while ((itemHit != 1) && (itemHit != 3)) {
ModalDialog(filterProc, itemHitPtr);
if (itemHit == 2) { /* set defaults */
j = 0;
for (i=0; i<7; i++) {
c = dfltmap[i] >> 3;
tempmap[j++] = (c & 0x10) >> 4;
tempmap[j++] = (c & 0x08) >> 3;
tempmap[j++] = (c & 0x04) >> 2;
tempmap[j++] = (c & 0x02) >> 1;
tempmap[j++] = c & 0x01;
}
for (i=0; i < 35; i++) {
GetDItem(dlgptr, i+18, >ype, &gitem, &gbox);
SetCtlValue(gitem, tempmap[i]);
}
}
else {
i = itemHit - 18;
tempmap[i] ^= 1;
GetDItem(dlgptr, itemHit, >ype, &gitem, &gbox);
SetCtlValue(gitem, tempmap[i]);
}
}
if (itemHit == 1) {
j = 0;
for (i=0; i<7; i++) {
c = (tempmap[j]<<4) + (tempmap[j+1]<<3) + (tempmap[j+2]<<2) +
(tempmap[j+3]<<1) + tempmap[j+4];
j += 5;
c <<= 3;
cs.attrmap[i] = c;
}
if (myWindow != 0) invldscr();
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
commdlg()
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short * itemHitPtr;
short itemHit, oldHit;
short gtype;
Handle gitem;
Rect gbox;
unsigned char s[256];
char d_hostname[128];
char d_setsflg, d_dblevel;
unsigned char d_timeout, d_retries, d_autoconn;
short i;
int r;
pascal unsigned short DlgFilter();
dStorage = 0;
behind = (WindowPtr)-1;
if (specuser) i = 258;
else i = 262;
dlgptr = GetNewDialog(i, dStorage, behind);
ctrwindow(dlgptr);
/* copy current values of items */
movmem(cshostname, d_hostname, 128);
d_setsflg = cs.setsflg;
d_dblevel = cs.dblevel;
d_timeout = cs.timeout;
d_retries = cs.retries;
d_autoconn = cs.autoconn;
/* show current values of items */
setcomm(dlgptr, d_hostname, d_setsflg, d_timeout, d_retries,
d_dblevel, d_autoconn);
/* select host name text */
SelIText(dlgptr, 5, 0, 32767);
/* Make Default is only for TCP */
if (!tcpflg && !specuser) {
GetDItem(dlgptr, 6, >ype, &gitem, &gbox);
HiliteControl(gitem, 255);
}
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
oldHit = 0;
while (1) {
ModalDialog(filterProc, itemHitPtr);
if ((oldHit > 0) && (oldHit != itemHit))
switch(oldHit) {
case 5: /* hostname */
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, s);
if (d_setsflg == 2) {
if (strlen(s) > 127) s[127] = 0;
}
else if (strlen(s) > 31) s[31] = 0;
i = 0;
while (s[i] != 0) {
if (d_setsflg == 2) d_hostname[i] = s[i];
else d_hostname[i] = toupper(s[i]);
i++;
}
d_hostname[i] = 0;
SetIText(gitem, d_hostname);
break;
case 12: /* timeout */
case 14: /* retries */
case 16: /* debug level */
GetDItem(dlgptr, oldHit, >ype, &gitem, &gbox);
GetIText(gitem, s);
if (sscanf(s, "%d", &r) != 1) r = 0;
if (oldHit == 12) {
if ((r > 0) && (r <= 10)) d_timeout = r;
sprintf(s, "%2d", d_timeout);
}
else if (oldHit == 14) {
if ((r > 0) && (r <= 99)) d_retries = r;
sprintf(s, "%2d", d_retries);
}
else {
if ((r >= 0) && (r <= 127)) d_dblevel = r;
sprintf(s, "%2d", d_dblevel);
}
SetIText(gitem, s);
break;
default:
break;
}
oldHit = itemHit;
switch(itemHit) {
case 1: /* OK */
movmem(d_hostname, cshostname, 128);
cs.setsflg = d_setsflg;
cs.dblevel = d_dblevel; /* copy new settings */
cs.timeout = d_timeout;
cs.retries = d_retries;
cs.autoconn = d_autoconn;
break;
case 2: /* set defaults */
d_setsflg = dfltsflg;
if (d_setsflg == 2) tcpdflthost(d_hostname);
else if (d_setsflg == 1) serdflthost(d_hostname);
else netdflthost(d_hostname);
d_autoconn = 1;
if (specuser) {
d_dblevel = 0;
d_timeout = 1;
d_retries = 15;
}
setcomm(dlgptr, d_hostname, d_setsflg,
d_timeout, d_retries, d_dblevel, d_autoconn);
i = strlen(d_hostname);
SelIText(dlgptr, 5, i, i);
break;
case 6: /* Make Default for host name */
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, s);
updhostrsc(s);
break;
case 7: /* auto-connect check box */
d_autoconn ^= 1;
setit(7, dlgptr, d_autoconn);
break;
case 8: /* AppleTalk */
case 9: /* Serial */
case 10: /* TCP/IP */
d_setsflg = itemHit - 8;
GetDItem(dlgptr, 8, >ype, &gitem, &gbox);
SetCtlValue(gitem, d_setsflg == 0);
GetDItem(dlgptr, 9, >ype, &gitem, &gbox);
SetCtlValue(gitem, d_setsflg == 1);
GetDItem(dlgptr, 10, >ype, &gitem, &gbox);
SetCtlValue(gitem, d_setsflg == 2);
break;
default: break;
}
if ((itemHit == 1) || (itemHit == 3)) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
setcomm(dlgptr, hname, sflg, timeout, retries, debug, autoconn)
DialogPtr dlgptr;
char * hname;
char sflg, debug, autoconn;
unsigned char timeout, retries;
{
short gtype;
Handle gitem;
Rect gbox;
char s[40];
GetDItem(dlgptr, 5, >ype, &gitem, &gbox); /* hostname */
SetIText(gitem, hname);
setit(7, dlgptr, autoconn); /* auto-connect */
if (!specuser) return;
GetDItem(dlgptr, 8, >ype, &gitem, &gbox); /* AppleTalk */
SetCtlValue(gitem, sflg == 0);
GetDItem(dlgptr, 9, >ype, &gitem, &gbox); /* Serial */
SetCtlValue(gitem, sflg == 1);
GetDItem(dlgptr, 10, >ype, &gitem, &gbox); /* TCP/IP */
SetCtlValue(gitem, sflg == 2);
GetDItem(dlgptr, 12, >ype, &gitem, &gbox); /* timeout */
sprintf(s, "%2d", timeout);
SetIText(gitem, s);
GetDItem(dlgptr, 14, >ype, &gitem, &gbox); /* retries */
sprintf(s, "%2d", retries);
SetIText(gitem, s);
GetDItem(dlgptr, 16, >ype, &gitem, &gbox); /* debug level */
sprintf(s, "%2d", debug);
SetIText(gitem, s);
}
OSErr hostdlg(s)
unsigned char *s; /* "s" assumed to be 128 bytes */
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short itemHit, oldHit;
short gtype;
Handle gitem;
Rect gbox;
unsigned char d_hostname[256];
OSErr rc;
pascal unsigned short DlgFilter();
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(282, dStorage, behind);
ctrwindow(dlgptr);
/* copy current values of items */
movmem(s, d_hostname, 256);
/* define host name text */
GetDItem(dlgptr, 4, >ype, &gitem, &gbox); /* hostname */
SetIText(gitem, d_hostname);
SelIText(dlgptr, 4, 0, 32767);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
oldHit = 0;
rc = 1; /* assume "cancel" */
while (1) {
ModalDialog(filterProc, &itemHit);
if ((oldHit > 0) && (oldHit != itemHit))
switch(oldHit) {
case 4: /* hostname */
GetDItem(dlgptr, 4, >ype, &gitem, &gbox);
GetIText(gitem, d_hostname);
if (strlen(d_hostname) > 127) {
d_hostname[127] = 0;
}
SetIText(gitem, d_hostname);
break;
default:
break;
}
oldHit = itemHit;
switch(itemHit) {
case 1: /* OK */
strcpy(s, d_hostname);
rc = 0;
break;
default: break;
}
if ((itemHit == 1) || (itemHit == 2)) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
return(rc);
}
featdlg()
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short itemHit;
char d_insreset, d_impnull, d_repnull, d_digitpfk, d_ext3270, d_std_brack;
pascal unsigned short DlgFilter();
static char * ScrDmpEnb = (char *)0x2f8;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(260, dStorage, behind);
ctrwindow(dlgptr);
/* copy current values of items */
d_insreset = cs.insreset;
d_impnull = cs.impnull;
d_repnull = cs.repnull;
d_digitpfk = cs.digitpfk;
d_ext3270 = cs.ext3270;
d_std_brack = cs.std_brack;
/* show current values of items */
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk, d_ext3270,
d_std_brack);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
while (1) {
ModalDialog(filterProc, &itemHit);
switch(itemHit) {
case 1: /* OK */
cs.insreset = d_insreset;
cs.impnull = d_impnull;
cs.repnull = d_repnull;
cs.digitpfk = d_digitpfk;
cs.ext3270 = d_ext3270;
cs.std_brack = d_std_brack;
fixbracket = cs.std_brack && (!aplmode) && (stdfont != ALAFONT);
if (cs.digitpfk) (*ScrDmpEnb) = 0;
else (*ScrDmpEnb) = ScrDmpSav;
break;
case 3: /* yes */
case 4: /* no */
d_insreset = 4 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 6: /* yes */
case 7: /* no */
d_impnull = 7 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 9: /* yes */
case 10: /* no */
d_repnull = 10 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 12: /* yes */
case 13: /* no */
d_digitpfk = 13 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 15: /* yes */
case 16: /* no */
d_ext3270 = 16 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 18: /* yes */
case 19: /* no */
d_std_brack = 19 - itemHit;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
case 20: /* set defaults */
d_insreset = d_impnull = d_repnull = d_digitpfk = d_ext3270 =
d_std_brack = 1;
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk,
d_ext3270, d_std_brack);
break;
default: break;
}
if ((itemHit == 1) || (itemHit == 21)) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
setfeat(dlgptr, d_insreset, d_impnull, d_repnull, d_digitpfk, d_ext3270,
d_std_brack)
DialogPtr dlgptr;
char d_insreset, d_impnull, d_repnull, d_digitpfk, d_ext3270, d_std_brack;
{
setit(3, dlgptr, d_insreset != 0); /* yes */
setit(4, dlgptr, d_insreset == 0); /* no */
setit(6, dlgptr, d_impnull != 0); /* yes */
setit(7, dlgptr, d_impnull == 0); /* no */
setit(9, dlgptr, d_repnull != 0); /* yes */
setit(10, dlgptr, d_repnull == 0); /* no */
setit(12, dlgptr, d_digitpfk != 0); /* yes */
setit(13, dlgptr, d_digitpfk == 0); /* no */
setit(15, dlgptr, d_ext3270 != 0); /* yes */
setit(16, dlgptr, d_ext3270 == 0); /* no */
setit(18, dlgptr, d_std_brack != 0); /* yes */
setit(19, dlgptr, d_std_brack == 0); /* no */
}
savedlg()
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short * itemHitPtr;
short itemHit;
pascal unsigned short DlgFilter();
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(261, dStorage, behind);
ctrwindow(dlgptr);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* loop to process changes */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
while (1) {
ModalDialog(filterProc, itemHitPtr);
if (itemHit == 1) break;
if (itemHit == 2) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
return(2 - itemHit);
}
clickdlg()
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short gtype;
Handle gitem;
Rect gbox, mybox;
void (*myitem) ();
short itemHit;
short * itemHitPtr;
short savepf, temppf;
GrafPtr gp;
pascal unsigned short DlgFilter();
pascal void attndlg();
pascal void attnmenu(short, MenuHandle,
Rect *, Point, short *);
/* long lpoint; */
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(266, dStorage, behind);
ctrwindow(dlgptr);
/* define routine to draw user item */
GetDItem(dlgptr, 4, >ype, &gitem, &mybox);
myitem = attndlg;
SetDItem(dlgptr, 4, gtype, myitem, &mybox);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
itemHit = 99;
itemHitPtr = &itemHit;
filterProc = DlgFilter;
savepf = cs.mousepf;
while ((itemHit != 1) && (itemHit != 3)) {
ModalDialog(filterProc, itemHitPtr);
switch(itemHit) {
case 1: /* OK */
break;
case 2: /* Set Default */
mousehit.v = mybox.top + 85;
mousehit.h = mybox.left + 279;
GetPort(&gp);
SetPort(dlgptr);
LocalToGlobal(&mousehit);
SetPort(gp);
case 4: /* Function Keys */
GetPort(&gp);
SetPort(dlgptr);
GlobalToLocal(&mousehit);
/* movmem(&mousehit, &lpoint, 4); struct -> long */
temppf = cs.mousepf;
attnmenu(mChooseMsg, (MenuHandle)0, &mybox,
mousehit, &cs.mousepf);
if (cs.mousepf == 0) {
cs.mousepf = temppf;
attnmenu(mChooseMsg, (MenuHandle)0, &mybox,
mousehit, &cs.mousepf);
cs.mousepf = temppf;
}
SetPort(gp);
break;
case 3: /* Cancel */
cs.mousepf = savepf;
break;
default:
break;
}
}
DisposDialog(dlgptr);
}
stgalert(kind, routine, amount)
char * kind;
char * routine;
long amount;
{
char message[80];
pascal unsigned short DlgFilter();
unsigned short (*filterProc) ();
filterProc = DlgFilter;
sprintf(message, "%s attempt to allocate %ld bytes for %s failed.",
routine, amount, kind);
dbdlg(message);
StopAlert(263, filterProc);
}
/* code taken from dbprint */
dbdlg(string)
char *string;
{
DialogRecord dStorage;
Rect boundry;
char visible = 0, goAway = 0;
WindowPtr behind = (WindowPtr)-1;
struct {
short numitems;
/* Button stuff */
long Bhandle;
short Btop,
Bleft,
Bbottom,
Bright;
char Btype;
char Blen;
char Btext[2];
/* Text item */
long Thandle;
short Ttop,
Tleft,
Tbottom,
Tright;
char Ttype;
char Tlen;
char Ttext[255];
} DStruct;
DialogPtr theBox;
short dummy, l;
Size DSsize;
Handle itemlist;
pascal unsigned short DlgFilter();
unsigned short (*filterProc) ();
OSErr rc;
if (cs.dblevel == 0) return;
if (mf_bgrnd && notifyavail) {
c2pstr(string);
rc = notifymsg(string);
p2cstr(string);
if (rc == noErr) return;
}
filterProc = DlgFilter;
DStruct.numitems = 1;
DStruct.Thandle = 0;
DStruct.Ttop = 50;
DStruct.Tleft = 30;
DStruct.Tbottom = 100;
DStruct.Tright = 260;
DStruct.Ttype = statText + itemDisable;
l = strlen(string);
if (l > 254) l = 254;
strcpy(DStruct.Ttext, string);
if (l%2) {
strcat(DStruct.Ttext, " ");
l++;
}
DStruct.Tlen = l;
DStruct.Bhandle = 0;
DStruct.Btop = 10;
DStruct.Bleft = 160;
DStruct.Bbottom = 30;
DStruct.Bright = 240;
DStruct.Btype = ctrlItem + btnCtrl;
DStruct.Blen = 2;
DStruct.Btext[0] = 'O';
DStruct.Btext[1] = 'K';
boundry.top = 120;
boundry.left = 120;
boundry.bottom = 240;
boundry.right = 400;
DSsize = sizeof(DStruct) - 255 + l;
itemlist = NewHandle(DSsize);
movmem(&DStruct, *itemlist, (short) DSsize);
arrowcursor();
theBox = NewDialog(&dStorage, &boundry, "Debug Text",
visible, dBoxProc, behind, goAway, 0L, itemlist);
ctrwindow(theBox);
ShowWindow(theBox);
/* highlight the default item */
framedflt(theBox);
ModalDialog(filterProc, &dummy);
DisposDialog(theBox);
}
srvdlg(flag)
char flag;
{
static DialogRecord dlgrec;
static DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
switch (flag) {
case 0: dStorage = &dlgrec;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(259, dStorage, behind);
ctrwindow(dlgptr);
ShowWindow(dlgptr);
DrawDialog(dlgptr);
return;
default:
DisposDialog(dlgptr);
return;
}
}
note_err(code)
short code;
{
pascal unsigned short DlgFilter();
unsigned short (*filterProc) ();
Handle errtext;
static char nullstr[1] = {0};
if (apiopen) {
if (apiopenreq.noalert) return;
}
errtext = GetResource('STR ', code);
if (errtext == 0) return;
if (mf_bgrnd && notifyavail) {
if (notifymsg(*errtext) == noErr) return;
}
ptoc(*errtext);
ParamText(*errtext, nullstr, nullstr, nullstr);
ctop(*errtext);
filterProc = DlgFilter;
arrowcursor();
if (code == mapalrt) {
NoteAlert(278, filterProc); /* appears only once */
}
else {
NoteAlert(281, filterProc); /* appears always */
}
ParamText(nullstr, nullstr, nullstr, nullstr);
}
stoperr(code)
short code;
{
pascal unsigned short DlgFilter();
unsigned short (*filterProc) ();
Handle errtext;
static char nullstr[1] = {0};
if (apiopen) {
if (apiopenreq.noalert) return;
}
errtext = GetResource('STR ', code);
if (errtext == 0) return;
if (mf_bgrnd && notifyavail) {
if (notifymsg(*errtext) == noErr) return;
}
ptoc(*errtext);
ParamText(*errtext, nullstr, nullstr, nullstr);
ctop(*errtext);
filterProc = DlgFilter;
arrowcursor();
StopAlert(264, filterProc);
ParamText(nullstr, nullstr, nullstr, nullstr);
}
stopterr(text)
unsigned char *text;
{
pascal unsigned short DlgFilter();
unsigned short (*filterProc) ();
static char nullstr[1] = {0};
OSErr rc;
if (apiopen) {
if (apiopenreq.noalert) return;
}
if (mf_bgrnd && notifyavail) {
ctop(text);
rc = notifymsg(text);
ptoc(text);
if (rc == noErr) return;
}
ParamText(text, nullstr, nullstr, nullstr);
filterProc = DlgFilter;
arrowcursor();
StopAlert(264, filterProc);
ParamText(nullstr, nullstr, nullstr, nullstr);
}
OSErr notifymsg(msg)
unsigned char *msg; /* Pascal string */
{
short i, n;
nmrmessage *nmp;
OSErr rc;
extern nmproc();
n = -1;
for (i=0; i < NMRNUM; i++) {
if (myNMR[i]->qelem.nmRefCon == 0) {
n = i;
break;
}
}
if (n == -1) return(1);
nmp = myNMR[n];
/* copy message text to message structure */
memcpy(nmp->msg, "\ptn3270: ", 9);
i = msg[0];
if (i > 247) i = 247;
memcpy(nmp->msg+9, msg+1, i);
nmp->msg[0] += i;
/* define notification manager request */
memset(&nmp->qelem, 0, sizeof(NMRec));
nmp->qelem.qType = nmType;
nmp->qelem.nmSound = (Handle)-1;
nmp->qelem.nmStr = nmp->msg;
nmp->qelem.nmResp = nmproc; /* calls nmend */
nmp->qelem.nmRefCon = GetA5();
rc = nminstall(&nmp->qelem);
if (rc != noErr) nmp->qelem.nmRefCon = 0;
return(rc);
}
nmend(nmReqPtr)
NMRecPtr nmReqPtr;
{
nmremove(nmReqPtr); /* dequeue request */
nmReqPtr->nmRefCon = 0; /* mark as available */
}
pascal unsigned short DlgFilter(dlg, eventptr, itemptr)
DialogPtr dlg;
EventRecord * eventptr;
short * itemptr;
{
char i;
if ((!serflg) && netconn) getreq();
if (tcpinitok) myStask();
switch(eventptr->what) {
case mouseDown:
mousehit = eventptr->where;
return(0);
case keyDown:
i = (eventptr->message & 0x7f); /* ascii code */
if ((i == 0x03) || (i == 0x0d)) {
(*itemptr) = 1;
return(-1);
}
default:
return(0);
}
}
pascal unsigned short fmtDlgFilter(dlg, eventptr, itemptr)
DialogPtr dlg;
EventRecord * eventptr;
short * itemptr;
{
short i;
GrafPtr gp;
Point mouseLoc;
short gtype;
Handle gitem;
Rect gbox, toprect, bottomrect;
if ((!serflg) && netconn) getreq();
if (tcpinitok) myStask();
switch(eventptr->what) {
case mouseDown:
case mouseUp:
GetPort(&gp);
SetPort(dlg);
mouseLoc = eventptr->where;
GlobalToLocal(&mouseLoc);
SetPort(gp);
GetDItem(dlg, 19, >ype, &gitem, &gbox);
if (PtInRect(&mouseLoc, &gbox)) {
if ((eventptr->what) == mouseUp) {
(*itemptr) = 19;
return(-1);
}
toprect = bottomrect = gbox;
toprect.bottom = bottomrect.top =
(gbox.top + gbox.bottom) / 2;
GetDItem(dlg, 18, >ype, &gitem, &gbox);
arrowinc(dlg, 18, gitem, &toprect, &bottomrect, 24, fmtmaxrows);
(*itemptr) = 17;
return(-1);
}
GetDItem(dlg, 22, >ype, &gitem, &gbox);
if (PtInRect(&mouseLoc, &gbox)) {
if ((eventptr->what) == mouseUp) {
(*itemptr) = 22;
return(-1);
}
toprect = bottomrect = gbox;
toprect.bottom = bottomrect.top =
(gbox.top + gbox.bottom) / 2;
GetDItem(dlg, 21, >ype, &gitem, &gbox);
arrowinc(dlg, 21, gitem, &toprect, &bottomrect, 80, fmtmaxcols);
(*itemptr) = 20;
return(-1);
}
return(0);
case keyDown:
i = (eventptr->message & 0x7f); /* ascii code */
if ((i == 0x03) || (i == 0x0d)) {
(*itemptr) = 1;
return(-1);
}
default:
return(0);
}
}
arrowinc(dlg, item, gitem, increct, decrect, min, max)
DialogPeek dlg;
short item;
Handle gitem;
Rect *increct, *decrect;
short min, max;
{
char result[256];
register short num;
static unsigned long * Ticks = (unsigned long *)0x16a;
unsigned long ticklim;
GrafPtr gp;
Point mouseLoc;
/* get initial value of item, and make valid if necessary */
GetIText(gitem, result);
num = atoi(result);
if (num < min) num = min;
if (num > max) num = max;
sprintf(result, "%d", num);
SetIText(gitem, result);
if (item == (dlg->editField)+1) {
SelIText(dlg, item, 0, 32767);
}
/* change value while mouse is down and in rectangle */
ticklim = (*Ticks);
while (StillDown()) {
if ((*Ticks) >= ticklim) {
ticklim = (*Ticks) + 7;
GetPort(&gp);
SetPort(dlg);
GetMouse(&mouseLoc);
SetPort(gp);
if (PtInRect(&mouseLoc, increct)) {
if (num == max) continue;
num++;
}
else if (PtInRect(&mouseLoc, decrect)) {
if (num == min) continue;
num--;
}
else continue;
sprintf(result, "%d", num);
SetIText(gitem, result);
if (item == (dlg->editField)+1) {
SelIText(dlg, item, 0, 32767);
}
}
}
}
pascal unsigned short ListDlgFilter(dlg, eventptr, itemptr)
DialogPtr dlg;
EventRecord * eventptr;
short * itemptr;
{
char i;
Rect itemRect;
short itemType;
Handle itemHandle;
Point where;
ListHandle list;
GrafPtr gp;
if ((!serflg) && netconn) getreq();
if (tcpinitok) myStask();
switch(eventptr->what) {
case mouseDown:
GetPort(&gp);
SetPort(dlg);
GetDItem(dlg, 14, &itemType, &itemHandle, &itemRect);
where = eventptr->where;
GlobalToLocal(&where);
if (PtInRect(&where, &itemRect)) {
*itemptr = 14;
itemRect.right -= 15;
if (PtInRect(&where, &itemRect)) {
*itemptr = 15;
}
list = (ListHandle)((DialogPeek)dlg)->window.refCon;
LClick(&where, eventptr->modifiers, list);
SetPort(gp);
return(-1);
}
else {
SetPort(gp);
return(0);
}
break;
case keyDown:
i = (eventptr->message & 0x7f); /* ascii code */
if ((i == 0x03) || (i == 0x0d)) {
(*itemptr) = 1;
return(-1);
}
default:
return(0);
}
}
xfdlg(code, msg1, msg2, msg3, msg4)
register short code;
register char * msg1;
register char * msg2;
char * msg3;
char * msg4;
{
static DialogRecord dlgrec;
static char msg1flg;
DialogPeek dStorage;
WindowPtr behind;
GrafPtr temp;
struct WStateData * wsptr;
struct WindowRecord * xtemp;
switch (code) {
case 0:
dStorage = &dlgrec;
behind = (WindowPtr)-1;
xdlgptr = GetNewDialog(267, dStorage, behind);
ctrwindow(xdlgptr);
ShowWindow(xdlgptr);
xtemp = (struct WindowRecord *)xdlgptr;
if (xtemp->dataHandle != 0) {
wsptr = (struct WStateData *)*(xtemp->dataHandle);
wsptr->stdState = xdlgptr->portRect;
GetPort(&temp);
SetPort(xdlgptr);
LocalToGlobal(&(wsptr->stdState.top));
LocalToGlobal(&(wsptr->stdState.bottom));
SetPort(temp);
}
xdlg = 1;
msg1flg = 0;
return;
case 1:
if (msg1flg == 0) {
msg1flg = 1;
settext(xdlgptr, 1, msg1);
}
settext(xdlgptr, 3, msg2);
settext(xdlgptr, 5, msg3);
settext(xdlgptr, 7, msg4);
xfGrowIcon();
return;
default:
if (xdlg == 0) return;
xdlg = 0;
DisposDialog(xdlgptr);
return;
}
}
fmtdlg()
{
register DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
pascal unsigned short DlgFilter();
pascal void arrowproc();
short itemHit, lasthit;
short * itemHitPtr;
short gtype;
Handle gitem;
Rect gbox;
void (*myitem) ();
short dfltptsize, altptsize;
short altrows, altcols;
short custrows, custcols;
char windmax, changed, customflag, skipflag, savewpos;
unsigned char result[256], newnum[10];
short i;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(269, dStorage, behind);
ctrwindow(dlgptr);
filterProc = fmtDlgFilter;
itemHitPtr = &itemHit;
/* define routine to draw user items */
GetDItem(dlgptr, 19, >ype, &gitem, &gbox);
myitem = arrowproc;
SetDItem(dlgptr, 19, gtype, myitem, &gbox);
GetDItem(dlgptr, 22, >ype, &gitem, &gbox);
myitem = arrowproc;
SetDItem(dlgptr, 22, gtype, myitem, &gbox);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
/* copy current settings */
windmax = cs.windmax;
dfltptsize = cs.dfltptsize;
altptsize = cs.altptsize;
altrows = cs.altrows;
altcols = cs.altcols;
custrows = cs.custrows;
custcols = cs.custcols;
savewpos = cs.savewpos;
/* adjust settings to be valid */
adjfmt(&changed, &windmax, &dfltptsize, &altptsize, &altrows, &altcols);
if (altptsize == 9) {
fmtmaxrows = rowmax9;
fmtmaxcols = colmax9;
}
else {
fmtmaxrows = rowmax12;
fmtmaxcols = colmax12;
}
if (custrows < 24) custrows = 24;
if (custcols < 80) custcols = 80;
if (custrows > fmtmaxrows) custrows = fmtmaxrows;
if (custcols > fmtmaxcols) custcols = fmtmaxcols;
if (((altrows == 24) && (altcols == 80)) ||
((altrows == 32) && (altcols == 80)) ||
((altrows == 43) && (altcols == 80)) ||
((altrows == 27) && (altcols == 132))) {
customflag = 0;
}
else {
customflag = 1;
custrows = altrows;
custcols = altcols;
}
/* display initial settings */
setfmt(dlgptr, 99, dfltptsize, windmax, altptsize,
altrows, altcols, customflag, custrows, custcols, savewpos);
itemHit = 99;
lasthit = 99;
while (1) {
ModalDialog(filterProc, itemHitPtr);
if (((lasthit == 18) && (itemHit != 18)) ||
((lasthit == 21) && (itemHit != 21)) ||
(itemHit == 19) || (itemHit == 22)) {
if ((lasthit == 18) || (itemHit == 19)) {
GetDItem(dlgptr, 18, >ype, &gitem, &gbox);
GetIText(gitem, result);
custrows = atoi(result);
if (custrows < 24) custrows = 24;
if (custrows > fmtmaxrows) custrows = fmtmaxrows;
if (customflag) altrows = custrows;
}
else {
GetDItem(dlgptr, 21, >ype, &gitem, &gbox);
GetIText(gitem, result);
custcols = atoi(result);
if (custcols < 80) custcols = 80;
if (custcols > fmtmaxcols) custcols = fmtmaxcols;
if (customflag) altcols = custcols;
}
}
if (itemHit < 3) break;
skipflag = 0;
switch (itemHit) {
case 3: dfltptsize = altptsize = 12;
windmax = 0;
altrows = 24;
altcols = 80;
adjfmt(&changed, &windmax, &dfltptsize,
&altptsize, &altrows, &altcols);
if (altptsize == 9) {
fmtmaxrows = rowmax9;
fmtmaxcols = colmax9;
}
else {
fmtmaxrows = rowmax12;
fmtmaxcols = colmax12;
}
customflag = 0;
custcols = fmtmaxcols;
custrows = fmtmaxrows;
break;
case 5: dfltptsize = 9;
break;
case 6: dfltptsize = 12;
break;
case 7: windmax ^= 1;
break;
case 8: savewpos ^= 1;
break;
case 10: altptsize = 9;
fmtmaxrows = rowmax9;
fmtmaxcols = colmax9;
break;
case 11: altptsize = 12;
fmtmaxrows = rowmax12;
fmtmaxcols = colmax12;
if (custrows > fmtmaxrows) custrows = fmtmaxrows;
if (custcols > fmtmaxcols) custcols = fmtmaxcols;
if (customflag) {
altrows = custrows;
altcols = custcols;
}
else {
if ((altrows > fmtmaxrows) || (altcols > fmtmaxcols)) {
altrows = 24;
altcols = 80;
}
}
break;
case 12: altrows = 24;
altcols = 80;
customflag = 0;
break;
case 13: altrows = 32;
altcols = 80;
customflag = 0;
break;
case 14: altrows = 43;
altcols = 80;
customflag = 0;
break;
case 15: altrows = 27;
altcols = 132;
customflag = 0;
break;
case 16: /* "custom" button and arrows */
case 19:
case 22:
altrows = custrows;
altcols = custcols;
customflag = 1;
break;
case 18:
case 21:
altrows = custrows; /* include selecting "custom" */
altcols = custcols;
customflag = 1;
GetDItem(dlgptr, itemHit, >ype, &gitem, &gbox);
GetIText(gitem, result);
i = 0;
while (result[i] != 0) {
if ((result[i] != 0x20) && ((result[i] < 0x30) ||
(result[i] > 0x39))) {
SysBeep(1);
break;
}
i++;
}
i = atoi(result) % 1000;
if (i == 0) {
newnum[0] = 0;
}
else {
sprintf(newnum, "%d", i);
}
if (strcmp(result, newnum) != 0) SetIText(gitem, newnum);
break;
default:
skipflag = 1;
break;
}
if (!skipflag) setfmt(dlgptr, itemHit, dfltptsize, windmax, altptsize,
altrows, altcols, customflag, custrows, custcols, savewpos);
lasthit = itemHit;
}
DisposDialog(dlgptr);
if (itemHit == 1) {
cs.windmax = windmax;
cs.dfltptsize = dfltptsize;
cs.altptsize = altptsize;
cs.altrows = altrows;
cs.altcols = altcols;
cs.custrows = custrows;
cs.custcols = custcols;
cs.savewpos = savewpos;
newwindfmt(); /* make changes now if possible */
}
}
setfmt(dlgptr, itemHit, dfltptsize, windmax, altptsize,
altrows, altcols, customflag, custrows, custcols, savewpos)
DialogPtr dlgptr;
short itemHit, dfltptsize, altptsize, altrows, altcols;
short custrows, custcols;
char windmax, customflag, savewpos;
{
short crows, ccols;
short gtype;
Handle gitem;
Rect gbox;
unsigned char result[256], newnum[10];
if (itemHit == 18) {
GetDItem(dlgptr, 18, >ype, &gitem, &gbox);
GetIText(gitem, result);
crows = atoi(result);
}
else crows = custrows;
if (itemHit == 21) {
GetDItem(dlgptr, 21, >ype, &gitem, &gbox);
GetIText(gitem, result);
ccols = atoi(result);
}
else ccols = custcols;
setactive(1, dlgptr,
!(customflag && ((crows > fmtmaxrows) || (ccols > fmtmaxcols) ||
(crows < 24) || (ccols < 80))));
setit(5, dlgptr, dfltptsize == 9);
setit(6, dlgptr, dfltptsize == 12);
setactive(6, dlgptr, (rowmax12 >= 24) && (colmax12 >= 80));
setit(7, dlgptr, windmax);
setit(8, dlgptr, savewpos);
setit(10, dlgptr, altptsize == 9);
setit(11, dlgptr, altptsize == 12);
setactive(11, dlgptr, (rowmax12 >= 24) && (colmax12 >= 80));
setit(12, dlgptr, (altrows == 24) && (altcols == 80) && (!customflag));
setit(13, dlgptr, (altrows == 32) && (altcols == 80) && (!customflag));
setactive(13, dlgptr, fmtmaxrows >= 32);
setit(14, dlgptr, (altrows == 43) && (altcols == 80) && (!customflag));
setactive(14, dlgptr, fmtmaxrows >= 43);
setit(15, dlgptr, (altrows == 27) && (altcols == 132) && (!customflag));
setactive(15, dlgptr, (fmtmaxrows >= 27) && (fmtmaxcols >= 132));
setit(16, dlgptr, customflag);
if (itemHit != 18) {
GetDItem(dlgptr, 18, >ype, &gitem, &gbox);
GetIText(gitem, result);
sprintf(newnum, "%d", custrows);
if (strcmp(result, newnum) != 0) {
SetIText(gitem, newnum);
}
}
if (itemHit != 21) {
GetDItem(dlgptr, 21, >ype, &gitem, &gbox);
GetIText(gitem, result);
sprintf(newnum, "%d", custcols);
if (strcmp(result, newnum) != 0) {
SetIText(gitem, newnum);
}
}
}
pascal void arrowproc(dlgwindow, item)
WindowPtr dlgwindow;
short item;
{
GrafPtr gp;
Rect myrect;
short dtype;
Handle ditem;
PolyHandle ph;
GetDItem(dlgwindow, item, &dtype, &ditem, &myrect);
GetPort(&gp);
SetPort(dlgwindow);
FrameRoundRect(&myrect, 8, 8);
ph = OpenPoly();
MoveTo(myrect.left+2, myrect.top+5);
LineTo(myrect.left+5, myrect.top+2);
LineTo(myrect.left+8, myrect.top+5);
LineTo(myrect.left+6, myrect.top+5);
LineTo(myrect.left+6, myrect.top+7);
LineTo(myrect.left+4, myrect.top+7);
LineTo(myrect.left+4, myrect.top+5);
LineTo(myrect.left+2, myrect.top+5);
ClosePoly();
FramePoly(ph);
PaintPoly(ph);
KillPoly(ph);
ph = OpenPoly();
MoveTo(myrect.left+2, myrect.top+12);
LineTo(myrect.left+5, myrect.top+15);
LineTo(myrect.left+8, myrect.top+12);
LineTo(myrect.left+6, myrect.top+12);
LineTo(myrect.left+6, myrect.top+10);
LineTo(myrect.left+4, myrect.top+10);
LineTo(myrect.left+4, myrect.top+12);
LineTo(myrect.left+2, myrect.top+12);
ClosePoly();
FramePoly(ph);
PaintPoly(ph);
KillPoly(ph);
SetPort(gp);
}
miscdlg()
{
register DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
pascal unsigned short ListDlgFilter();
short itemHit;
short * itemHitPtr;
short gtype;
Handle gitem;
Rect gbox;
void (*myitem) ();
short newtime, newblock, newpos;
GrafPtr gp;
pascal void misctext();
pascal void listproc();
ListHandle list;
Rect dataBounds;
Point cellSize, cell;
short i, sndcount, namelen;
char loadflag;
Handle reshandle, reshandle2;
short resid;
long restype;
char resname[256];
OSErr rc;
Handle getsndresource();
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(271, dStorage, behind);
ctrwindow(dlgptr);
if (newroms) {
filterProc = ListDlgFilter;
}
else {
filterProc = DlgFilter;
}
itemHitPtr = &itemHit;
GetPort(&gp);
SetPort(dlgptr);
/* define routine to draw user items */
GetDItem(dlgptr, 13, >ype, &gitem, &gbox);
myitem = misctext;
SetDItem(dlgptr, 13, gtype, myitem, &gbox);
GetDItem(dlgptr, 14, >ype, &gitem, &gbox);
myitem = listproc;
SetDItem(dlgptr, 14, gtype, myitem, &gbox);
if (newroms) {
/* make room for scroll bar */
gbox.right -= 15;
/* create a list */
dataBounds.top = dataBounds.left = 0;
sndcount = CountResources('snd ');
dataBounds.bottom = sndcount + 1;
dataBounds.right = 1;
cellSize.h = cellSize.v = 0; /* use defaults */
list = LNew(&gbox, &dataBounds, &cellSize, 0, (WindowPtr)dlgptr,
false, false, false, true);
/* allow the dialog manager routines to access the list record */
((DialogPeek)dlgptr)->window.refCon = (long)list;
/* allow only one selection at a time */
(*list)->selFlags = lOnlyOne;
}
else {
setactive(13, dlgptr, 0);
}
setit(4, dlgptr, cs.stat_time==1);
setit(5, dlgptr, cs.stat_time==2);
setit(6, dlgptr, cs.stat_time==0);
setit(8, dlgptr, cs.blockcurs==0);
setit(9, dlgptr, cs.blockcurs==1);
setit(11, dlgptr, cs.curpos==0);
setit(12, dlgptr, cs.curpos==1);
if (newroms) {
/* Initialize cell contents */
cell.h = cell.v = 0;
strcpy(resname, dfltsoundname);
namelen = strlen(resname);
LSetCell(resname, namelen, &cell, list);
if (strcmp(resname, cssndname) == 0) LSetSelect(true, &cell, list);
if (sndcount > 0) {
for (i=1; i <= sndcount; i++) {
cell.v++;
loadflag = 0;
SetResLoad(false);
reshandle = GetIndResource('snd ', i);
SetResLoad(true);
if (reshandle == 0) {
loadflag = 1;
reshandle = GetIndResource('snd ', i);
}
if (reshandle != 0) {
getsndinfo(reshandle, &resid, &restype, resname);
if (loadflag) ReleaseResource(reshandle);
namelen = strlen(resname);
LSetCell(resname, namelen, &cell, list);
if (strcmp(resname, cssndname) == 0)
LSetSelect(true, &cell, list);
}
}
}
LAutoScroll(list);
LDoDraw(true, list);
}
newtime = cs.stat_time;
newblock = cs.blockcurs;
newpos = cs.curpos;
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
itemHit = 99;
resname[0] = 0;
while (itemHit > 2) {
ModalDialog(filterProc, itemHitPtr);
switch (itemHit) {
case 4:
newtime = 1;
break;
case 5:
newtime = 2;
break;
case 6:
newtime = 0;
break;
case 8:
newblock = 0;
break;
case 9:
newblock = 1;
break;
case 11:
newpos = 0;
break;
case 12:
newpos = 1;
break;
case 14:
case 15:
if (!newroms) {
beep();
break;
}
resname[0] = 0;
cell.h = 0;
for (cell.v=0; cell.v < sndcount+1; cell.v++) {
if (LGetSelect(false, &cell, list)) {
namelen = 255;
LGetCell(resname, &namelen, &cell, list);
resname[namelen] = 0;
break;
}
}
if ((strlen(resname) > 0) && (itemHit == 15)) {
if (strcmp(resname, dfltsoundname) == 0) {
SysBeep(3);
}
else {
dlgplaysound(resname);
}
}
break;
default:
break;
}
if ((itemHit >= 4) && (itemHit <= 12)) {
setit(4, dlgptr, newtime==1);
setit(5, dlgptr, newtime==2);
setit(6, dlgptr, newtime==0);
setit(8, dlgptr, newblock==0);
setit(9, dlgptr, newblock==1);
setit(11, dlgptr, newpos==0);
setit(12, dlgptr, newpos==1);
}
}
if (newroms) {
LDispose(list);
}
SetPort(gp);
DisposDialog(dlgptr);
if (itemHit == 1) {
if (cs.stat_time != newtime) {
cs.stat_time = newtime;
if (myWindow != 0) newstat();
}
if (cs.blockcurs != newblock) {
cs.blockcurs = newblock;
if (myWindow != 0) newcur();
}
if (cs.curpos != newpos) {
cs.curpos = newpos;
if (myWindow != 0) newstat();
}
if ((strcmp(cssndname, resname) != 0) && (resname[0] != 0)) {
if (strcmp(resname, dfltsoundname) == 0) {
if (sndactive) {
SndDisposeChannel(scp, true);
sndactive = 0;
}
if (sndhandle != 0) DisposHandle(sndhandle);
sndhandle = 0;
strcpy(cssndname, resname);
}
else {
reshandle = reshandle2 = getsndresource(resname);
if (reshandle != 0) {
rc = HandToHand(&reshandle2);
if (rc != noErr) {
ReleaseResource(reshandle);
stoperr(sdmemalrt);
}
else {
getsndinfo(reshandle, &resid, &restype, resname);
ReleaseResource(reshandle);
if (sndactive) {
SndDisposeChannel(scp, true);
sndactive = 0;
}
if (sndhandle != 0) DisposHandle(sndhandle);
sndhandle = reshandle2;
strcpy(cssndname, resname);
}
}
}
}
}
}
dlgplaysound(sndname)
char * sndname;
{
Handle temph, temph2, getsndresource();
OSErr rc;
SndChannelPtr default_scp;
temph = temph2 = getsndresource(sndname);
if (temph == 0) return;
rc = HandToHand(&temph2);
ReleaseResource(temph);
if (rc == noErr) {
if (sndactive) {
SndDisposeChannel(scp, true);
sndactive = 0;
}
default_scp = 0;
rc = SndNewChannel(&default_scp, 0, 0L, 0L);
if (rc == noErr) {
SndPlay(default_scp, temph2, 0);
SndDisposeChannel(default_scp, 0);
}
DisposHandle(temph2);
}
}
pascal void listproc(dialog, itemNo)
DialogPtr dialog;
short itemNo;
{
ListHandle list;
short itemType;
Handle itemHandle;
Rect itemRect;
GetDItem(dialog, itemNo, &itemType, &itemHandle, &itemRect);
if (newroms) {
list = (ListHandle)((DialogPeek)dialog)->window.refCon;
LUpdate(dialog->visRgn, list);
}
InsetRect(&itemRect, -1, -1);
if (!newroms) PenPat(qd.gray);
FrameRect(&itemRect);
if (!newroms) PenPat(qd.black);
}
pascal void misctext(wp, inum)
WindowPtr wp;
short inum;
{
short gtype;
Handle gitem;
Rect gbox;
GrafPort mp;
GrafPtr gp;
OSErr dlgnewmap(), rc;
GetDItem(wp, inum, >ype, &gitem, &gbox);
rc = dlgnewmap(&mp, &gbox);
if (rc != 0) return;
GetPort(&gp);
SetPort(&mp);
MoveTo(gbox.left, gbox.top+12);
switch(inum) {
case 13:
DrawString("Beep Sound:");
break;
default:
break;
}
if (!newroms) {
PenPat(qd.gray);
PenMode(patBic);
PaintRect(&gbox);
}
SetPort(wp);
CopyBits(&mp.portBits, &(wp->portBits), &gbox, &gbox, srcCopy, 0L);
SetPort(gp);
ClosePort(&mp);
DisposPtr(dlgmapptr);
}
OSErr dlgnewmap(wp, box)
GrafPtr wp;
Rect * box;
{
BitMap dlgWriteMap;
Size mapsize;
Ptr myNewPtr();
GrafPtr gp;
dlgWriteMap.bounds = *box;
dlgWriteMap.rowBytes =
(dlgWriteMap.bounds.right - dlgWriteMap.bounds.left + 7) >> 3;
if (dlgWriteMap.rowBytes%2) dlgWriteMap.rowBytes++;
mapsize = dlgWriteMap.bounds.bottom - dlgWriteMap.bounds.top;
mapsize = mapsize * dlgWriteMap.rowBytes;
dlgmapptr = myNewPtr(mapsize);
if (dlgmapptr == 0L) return(4);
dlgWriteMap.baseAddr = dlgmapptr;
wp->portRect = dlgWriteMap.bounds;
GetPort(&gp);
OpenPort(wp);
SetPortBits(&dlgWriteMap);
EraseRgn(wp->visRgn);
SetPort(gp);
}
getsndinfo(theResource, theID, theType, name)
Handle theResource;
short *theID;
ResType *theType;
unsigned char *name;
{
short i, namelength;
GetResInfo(theResource, theID, theType, name);
namelength = strlen(name);
if (namelength > 0) {
for (i=0; i < namelength; i++) {
if (!isspace(name[i])) return;
}
}
/* if we get here, the name is null, or all white space */
/* generate a pseudo-name for the user and "getsndresource" */
sprintf(name, "(unnamed) #%d", *theID);
}
Handle getsndresource(name)
unsigned char *name;
{
int resnum;
if (strlen(name) > 11) {
if (strncmp(name, "(unnamed) #", 11) == 0) {
if (1 == sscanf(name+11, "%d", &resnum)) {
return(GetResource('snd ', resnum));
}
}
}
return(GetNamedResource('snd ', name));
}
void crsetdlg()
{
DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short * itemHitPtr;
short itemHit, oldHit;
short gtype;
Handle gitem;
Rect gbox;
union {
OSType type;
unsigned char name[4];
} cr;
unsigned char crstr[5];
unsigned char instr[256];
char showok;
OSErr rc;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(283, dStorage, behind);
ctrwindow(dlgptr);
/* copy current value of creator */
cr.type = cs.text_creator;
memcpy(crstr+1, cr.name, 4);
crstr[0] = 4;
/* define creator text */
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
p2cstr(crstr);
SetIText(gitem, crstr);
c2pstr(crstr);
SelIText(dlgptr, 5, 0, 32767);
/* handle file creator dialog */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
oldHit = 0;
showok = 1;
while (1) {
/* ModalDialog((ModalFilterProcPtr)filterProc, itemHitPtr); */
ModalDialog(filterProc, itemHitPtr);
if ((oldHit > 0) && (oldHit != itemHit))
switch(oldHit) {
case 5:
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, instr);
c2pstr(instr);
memcpy(crstr, instr, 5);
if (crstr[0] > 4) crstr[0] = 4;
while (crstr[0] < 4) {
crstr[crstr[0]+1] = ' ';
crstr[0]++;
}
break;
default:
break;
}
oldHit = itemHit;
switch(itemHit) {
case 1: /* OK */
memcpy(cr.name, crstr+1, 4);
cs.text_creator = cr.type;
break;
case 2: /* get from app. */
rc = getapcr(&cr.type);
if (rc != noErr) {
framedflt(dlgptr);
break;
}
if (!showok) {
showok = 1;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
HiliteControl((ControlHandle)gitem, 0);
}
framedflt(dlgptr);
memcpy(crstr+1, cr.name, 4);
crstr[0] = 4;
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
p2cstr(crstr);
SetIText(gitem, crstr);
c2pstr(crstr);
SelIText(dlgptr, 5, 0, 32767);
break;
case 5:
GetDItem(dlgptr, 5, >ype, &gitem, &gbox);
GetIText(gitem, instr);
c2pstr(instr);
if ((instr[0] < 1) || (instr[0] > 4)) {
if (showok) {
showok = 0;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
HiliteControl((ControlHandle)gitem, 255);
framedflt(dlgptr);
}
}
else {
if (!showok) {
showok = 1;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
HiliteControl((ControlHandle)gitem, 0);
framedflt(dlgptr);
}
}
break;
default: break;
}
if ((itemHit == 1) || (itemHit == 3)) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
void psdlg()
{
DialogPtr dlgptr;
Ptr dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short * itemHitPtr;
short itemHit;
short gtype;
Handle gitem;
Rect gbox;
OSErr rc;
char dlgps;
dStorage = 0;
behind = (WindowPtr)-1;
dlgptr = GetNewDialog(284, dStorage, behind);
ctrwindow(dlgptr);
/* copy current value of flag and display it */
dlgps = cs.simps;
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
SetCtlValue(gitem, dlgps);
/* handle PS simulation dialog */
filterProc = DlgFilter;
itemHitPtr = &itemHit;
ShowWindow(dlgptr);
/* frame the default selection */
framedflt(dlgptr);
while (1) {
/* ModalDialog((ModalFilterProcPtr)filterProc, itemHitPtr); */
ModalDialog(filterProc, itemHitPtr);
switch(itemHit) {
case 1: /* OK */
cs.simps = dlgps;
break;
case 2: /* Cancel */
break;
case 3: /* Check Box */
case 4:
dlgps ^= 1;
GetDItem(dlgptr, 3, >ype, &gitem, &gbox);
SetCtlValue(gitem, dlgps);
break;
default: break;
}
if (itemHit < 3) break;
}
/* dispose of dialog and return */
DisposDialog(dlgptr);
}
OSErr getapcr(cr)
OSType *cr;
{
Point where;
/* FileFilterProcPtr fileFilter; */
ProcPtr fileFilter;
short numTypes;
SFTypeList typeList;
/* DlgHookProcPtr dlgHook; */
ProcPtr dlgHook;
SFReply reply;
FileParam fblk;
FileParam * _fblk;
OSErr rc;
where = sfgpoint;
fileFilter = 0;
dlgHook = 0;
numTypes = 1;
typeList[0] = 'APPL';
SFGetFile(&where ,"",fileFilter,numTypes,
typeList,dlgHook,&reply);
if (reply.good == 0) return(1);
_fblk = &fblk;
fblk.ioCompletion = 0;
fblk.ioNamePtr = (StringPtr)&reply.fName;
fblk.ioVRefNum = reply.vRefNum;
fblk.ioFVersNum = 0;
fblk.ioFDirIndex = 0;
rc = PBGetFInfo((ParmBlkPtr)_fblk, 0);
if (rc != noErr) return(rc);
(*cr) = fblk.ioFlFndrInfo.fdCreator;
return(noErr);
}
setit(item, dlgptr, code)
register short item, code;
register DialogPtr dlgptr;
{
short gtype;
Handle gitem;
Rect gbox;
GetDItem(dlgptr, item, >ype, &gitem, &gbox);
SetCtlValue(gitem, code);
}
setactive(item, dlgptr, flag)
register short item;
register DialogPtr dlgptr;
register char flag;
{
short gtype;
Handle gitem;
Rect gbox;
GetDItem(dlgptr, item, >ype, &gitem, &gbox);
if (flag) {
HiliteControl(gitem, 0);
}
else {
HiliteControl(gitem, 255);
}
if (item == 1) framedflt(dlgptr);
}
short wants_to_quit()
/* if a session is in progress, verify user wants to quit */
{
pascal unsigned short DlgFilter();
unsigned short (*filterProc) ();
short item;
static char nullstr[1] = {0};
/* return TRUE if no connection established */
if (serflg) {
if (connflg) return(1); /* no serial 3270 connection */
}
else if (tcpflg) {
if (!tcp_session()) return(1); /* no TCP/IP 3270 or line mode connection */
}
else if (!netconn) return(1); /* no AppleTalk connection */
filterProc = DlgFilter;
arrowcursor();
ParamText(sessionhost, nullstr, nullstr, nullstr);
item = CautionAlert(279, filterProc);
ParamText(nullstr, nullstr, nullstr, nullstr);
if (item == 1) return(0); /* resume */
else return(1); /* end session */
}
dFullAlt(kShort)
register short kShort;
{
pascal unsigned short DlgFilter();
unsigned short (*filterProc) ();
char buf[10];
sprintf(buf, "%d", kShort);
ParamText(macFName+1, buf, macVName+1, "");
filterProc = DlgFilter;
arrowcursor();
StopAlert(265, filterProc);
}
settext(dlgptr, item, text)
register DialogPtr dlgptr;
register short item;
register char *text;
{
short gtype;
Handle gitem;
Rect gbox;
GetDItem(dlgptr, item, >ype, &gitem, &gbox);
SetIText(gitem, text);
}
ctrwindow(wp)
GrafPtr wp;
{
short scrhsize, scrvsize;
short whsize, wvsize;
scrhsize = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
scrvsize = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;
whsize = wp->portRect.right-wp->portRect.left;
wvsize = wp->portRect.bottom - wp->portRect.top;
MoveWindow(wp, (scrhsize-whsize)/2, (scrvsize-wvsize)/3, 0);
}
ctralrt(a)
short a; /* alert number */
{
Handle reshnd;
struct Rect * rptr;
short scrhsize, scrvsize;
short ahsize, avsize;
CouldAlert(a); /* read alert into memory and make unpurgeable */
reshnd = GetResource('ALRT', a);
if (reshnd == 0) return;
rptr = (struct Rect *)*reshnd;
scrhsize = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
scrvsize = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;
ahsize = rptr->right - rptr->left;
avsize = rptr->bottom - rptr->top;
rptr->top = (scrvsize-avsize)/3;
rptr->left = (scrhsize-ahsize)/2;
rptr->bottom = rptr->top + avsize;
rptr->right = rptr->left + ahsize;
}
framedflt(dlgptr)
DialogPtr dlgptr;
{
short gtype;
Handle gitem;
Rect gbox;
GrafPtr gp;
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
GetPort(&gp);
SetPort(dlgptr);
OutlineButton(gitem);
SetPort(gp);
}
OutlineButton(button)
ControlHandle button;
{
/* This routine provided by Macintosh DTS: */
/* Given any control handle, this will draw an outline around it. This is
used for the default button of a window. The extra nice feature here is
that I'll erase the outline for buttons that are inactive. Seems like
there should be a Toolbox call for getting a control's hilite state.
Since there isn't, I have to look into the control record myself. This
should be called for update and activate events.
The method for determining the oval diameters for the roundrect is a
little different than that recommended by Inside Mac. IM I-407 suggests
that you use a hardcoded (16,16) for the diameters. However, this only
looks good for small roundrects. For larger ones, the outline doesn't
follow the inner roundrect because the CDEF for simply buttons doesn't
use (16,16). Instead, it uses half the height of the button as the
diameter. By using this formula, too, our outlines look better. */
/* WARNING: This will set the current port to the control's window. */
Rect theRect;
PenState curPen;
short buttonOval;
if (button != 0) {
/* SetPort((*button)->contrlOwner); */ /* done by caller */
GetPenState(&curPen);
PenNormal();
theRect = (*button)->contrlRect;
InsetRect(&theRect, kButtonFrameInset, kButtonFrameInset);
buttonOval = (theRect.bottom - theRect.top) / 2;
if ((*button)->contrlHilite == 0) {
PenPat(qd.black);
}
else {
PenPat(qd.gray);
}
PenSize(kButtonFrameSize, kButtonFrameSize);
FrameRoundRect(&theRect, buttonOval, buttonOval);
SetPenState(&curPen);
}
}
arrowcursor()
{
if (!dfltcurs) {
dfltcurs = 1;
SetCursor(&qd.arrow);
}
}